from construct_vect import construct_vect

from iw import get_wifi_rssi

def construct_all_vectors(N):
    mac_list = []
    wifi_set = []
    for i in range(N):
        print("this is the ",i,"th dot.")
        aaa=get_wifi_rssi()
        mac_list=get_mac_list(mac_list,aaa)
        wifi_set.append(aaa)
        print("please move the car to next dot")
        # print("please input ok")
        while True:
            print("please input ",i,'\n')
            get_input=input()
            if get_input == i:
                break
    f = open('vector_list.txt','w')
    f.write('')
    for wifi_list in wifi_set:
        vector=construct_vect(wifi_list,mac_list)
        f = open('vector_list.txt','a')
        f.write(str(vector))
    return mac_list
def get_mac_list(mac_list,wifi_list):
    for wifi_element in wifi_list:
        if wifi_element['mac'] not in mac_list:
            mac_list.append(wifi_element['mac'])
    return mac_list
"""
construct the vectors of all dots as .txt
"""
if __name__ == "__main__":
    print("please input the number of dots you want to record. eg:4")
    N = input()
    N = int(N)
    mac_list=construct_all_vectors(N)
    f = open('mac_list.txt','w')
    f.write(str(mac_list))